﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DAL;

namespace BAL
{
    public class BAL_TyGiaDichVu
    {
       public QuanLyPhongTroDBDataContext dbs = new QuanLyPhongTroDBDataContext();
       public List<DanhSachTyGiaDichVuResult> LayTyGiaDichVu()
       {
           return dbs.DanhSachTyGiaDichVu().ToList();
       }
        public void ThemTyGiaDichVu(string maDV,string tyGia,DateTime ngayCN)
        {
            TyGiaDichVu tgdv=new TyGiaDichVu(){MaDichVu = maDV,TyGia = int.Parse(tyGia),NgayCapNhat = ngayCN};

            dbs.TyGiaDichVus.InsertOnSubmit(tgdv);
            dbs.SubmitChanges();
        }
        public void SuaTyGiaDichVu(string maDV,string tyGia,DateTime ngayCN)
        {
            TyGiaDichVu tgdv = dbs.TyGiaDichVus.Single(tgd => tgd.MaDichVu == maDV && tgd.NgayCapNhat == ngayCN);
            tgdv.TyGia = int.Parse(tyGia);
            dbs.SubmitChanges();
        }
        public void XoaTyGiaDichVu(string maDV,DateTime ngayCN)
        {
            TyGiaDichVu tgdv = dbs.TyGiaDichVus.Single(tgd => tgd.MaDichVu == maDV && tgd.NgayCapNhat == ngayCN);
           dbs.TyGiaDichVus.DeleteOnSubmit(tgdv);
            dbs.SubmitChanges();
        }
    }
}
